<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="authority/common/currency/head"></div>
    <link rel="stylesheet" th:href="@{/authority/css/form-auto.css}">
    <style>
        body {
            background-color: #F2F2F2;
        }

        .layui-quote-children {
            line-height: 12px;
        }

        .zsa-tab-title {
            top: 0;
            padding-top: 20px;
            width: 100%;
            position: fixed;
            z-index: 9999;
            background-color: #F2F2F2;
        }

        .zsa-tab-content {
            padding: 60px 0 20px 0;
        }
    </style>
</head>

<body class="childrenBody" padding10>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title zsa-tab-title">
        <li><a href="javascript:location.href = content_path + 'swagger-ui.html';">接口api</a></li>
        <li><a th:href="@{/authority/api/dml/help.html}">数据库DML相关属性</a></li>
        <li><a class="layui-this">查询/排序</a></li>
        <!--<li class=""><a th:href="@{/business/pack_list.html}"></a></li>-->
    </ul>
    <div class="layui-form layui-tab-content zsa-tab-content">
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">查询</h2>
                <div class="layui-colla-content">
                    <div class="layui-card">
                        <div class="layui-card-header">示列</div>
                        <div class="layui-card-body">
<pre class="layui-code">
// 简单 查询 name = '测试'
{
    "field": "name",
    "value": "测试"
}
// 查询日期 time = 2018(Data)
{
    "field": "time",
    "value": "2018",
    "type": "date",
    "dateType": "year"
}
// 多条件复杂查询 state IN(1,0) AND time IS NULL
{
    "formula": "AND",
    "params":
        [{
            "field": "state",
            "formula": "IN",
            "value": "1,0", // 或者："value": "[1,0]"
            "type": "INT" // 或者："type": "NUMBER"
        },{
            "field": "time", //这里虽然是时间类型 但是查询是否为空 所以可以不指定s
            "formula": "NULL"
        }]
}
或则
[{
    "field": "state",
    "formula": "IN",
    "value": "1,0", // 或者："value": "[1,0]"
    "type": "INT" // 或者："type": "NUMBER"
},{
    "field": "time", //这里虽然是时间类型 但是查询是否为空 所以可以不指定s
    "formula": "NULL"
}]

// 多条件复杂查询 name like '%测试%' OR type NOT IN('java,spring','数据库') AND age BETWEEN 1 AND 10
{
    "formula": "OR",
    "params":
        [{
            "field": "state",
            "formula": "<->",
            "value": "测试"
        },{
            "formula": "AND",
            "params":
                [{
                    "field": "type",
                    "formula": "NOTIN",
                    "value": "['java,spring','数据库']", // 逗号的原由，这里只能使用字符串数组
                    "type": "STRING"  // 这里默认STRING 所以可以去掉
                },{
                    "field": "age",
                    "formula": "range",
                    "value": "1~~10", // 查询年龄 1 到 10 岁的
                    "type": "NUMBER"
                }]
        }]
}
</pre>
                        </div>
                    </div>

                    <div class="layui-card">
                        <div class="layui-card-header">字段属性</div>
                        <div class="layui-card-body">
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>field（formula不是AND/OR时 必填）</b> &nbsp;&nbsp;
                                字段名（不能有特色符号或者中文）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>formula</b> &nbsp;&nbsp; 符号/公示（params为空时默认值：= ， params不为空时默认值： AND）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>params</b> &nbsp;&nbsp; 参数集合（复杂查询时使用）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>value</b> &nbsp;&nbsp;
                                值（除了formula="NULL" 或者 formula="NOTNULL"，以外必填）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>type</b> &nbsp;&nbsp;
                                字段类型（默认值：STRING）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>dateType</b> &nbsp;&nbsp;
                                日期格式（默认值：DATE）
                            </blockquote>
                        </div>
                    </div>
                    <div class="layui-card">
                        <div class="layui-card-header">数据类型 TYPE（值不区分大小写）</div>
                        <div class="layui-card-body">
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>STRING （默认）</b> &nbsp;&nbsp; 字符串类型
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>NUMBER</b> &nbsp;&nbsp; 数字类型(任意数字)
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>INT</b> &nbsp;&nbsp; INT</blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>LONG</b> &nbsp;&nbsp; LONG
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>DATE</b> &nbsp;&nbsp; 日期类型
                                <hr>
                                <blockquote class="layui-elem-quote layui-quote-nm layui-quote-children"><b>YEAR</b>
                                    &nbsp;&nbsp; 年份（格式： yyyy,列如：2019）
                                </blockquote>
                                <blockquote class="layui-elem-quote layui-quote-nm layui-quote-children"><b>MONTH</b>
                                    &nbsp;&nbsp; 月份（格式 yyyy-MM,列如：2019-01）
                                </blockquote>
                                <blockquote class="layui-elem-quote layui-quote-nm layui-quote-children"><b>DATE
                                    （默认）</b> &nbsp;&nbsp; 日期/天（格式 yyyy-MM-dd,列如：2019-01-01）
                                </blockquote>
                                <blockquote class="layui-elem-quote layui-quote-nm layui-quote-children"><b>TIME</b>
                                    &nbsp;&nbsp; 时间（格式 HH:mm:ss,列如：23:59:59）
                                </blockquote>
                                <blockquote class="layui-elem-quote layui-quote-nm layui-quote-children"><b>DATETIME</b>
                                    &nbsp;&nbsp; 完整时间（格式 yyyy-MM-dd hh24:mi:ss,列如：2019-01-01 23:59:59）
                                </blockquote>
                            </blockquote>
                        </div>
                    </div>

                    <div class="layui-card">
                        <div class="layui-card-header">查询符号/公式 FORMULA （值不区分大小写）</div>
                        <div class="layui-card-body">
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>AND</b> &nbsp;&nbsp; 条件之间的AND关系 (特殊) , params参数有值时 默认
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>OR</b> &nbsp;&nbsp; 条件之间的OR关系 (特殊)
                            </blockquote>

                            <blockquote class="layui-elem-quote layui-quote-nm"><b>=</b> &nbsp;&nbsp;
                                等于，除时间以外的全等匹配（列如：<b>name = ?</b>） params参数无值时 默认
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>NULL</b> &nbsp;&nbsp; 为空（列如：<b>name
                                is null</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>NOTNULL</b> &nbsp;&nbsp; 不为空 （列如：<b>name
                                is not null</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>&lt;&gt;</b> &nbsp;&nbsp;
                                不等于，除时间以外（列如：<b>name &lt;&gt; ?</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>&gt;</b> &nbsp;&nbsp; 大于，（列如：<b>name
                                &gt; ?</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>&lt;</b> &nbsp;&nbsp; 小于，（列如：<b>name
                                &lt; ?</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>IN</b> &nbsp;&nbsp; （列如：<b>name in
                                (?,?,?...)</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>NOTIN</b> &nbsp;&nbsp; （列如：<b>name
                                not in (?,?,?...)</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>&lt;-&gt;</b> &nbsp;&nbsp; 包含，字符串（列如：<b>name
                                like '%?%'</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>-&gt;</b> &nbsp;&nbsp; 开始于，字符串（列如：<b>name
                                like '?%'</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>&lt;-</b> &nbsp;&nbsp; 结束于，字符串（列如：<b>name
                                like '%?'</b>）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>range</b> &nbsp;&nbsp; 范围,必须格式 条件1~~条件2（列如：<b> name
                                between ? and ?</b>）
                            </blockquote>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">排序</h2>
                <div class="layui-colla-content">
                    <div class="layui-card">
                        <div class="layui-card-header">示列</div>
                        <div class="layui-card-body">
<pre class="layui-code">
// 简单 ORDER BY name ASC
[{
    "field": "name" //这里order默认值为 空 所以可以不指定，实际语句 ORDER BY name
}]
// 简单 ORDER BY name DESC
[{
    "field": "name",
    "order": "DESC"
}]
// 多个字段排序 ORDER BY name ASC,type DESC
[{
    "field": "name"
},{
    "field": "type",
    "order": "DESC"
}]

</pre>
                        </div>
                    </div>
                    <div class="layui-card">
                        <div class="layui-card-header">字段属性</div>
                        <div class="layui-card-body">
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>field（必填）</b> &nbsp;&nbsp;
                                字段名（不能有特色符号或者中文）
                            </blockquote>
                            <blockquote class="layui-elem-quote layui-quote-nm"><b>order</b> &nbsp;&nbsp; 排除方式（取值范围：ASC/DESC，默认值：空 也就是ASC）
                            </blockquote>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:replace="authority/common/currency/footer"></div>
<script type="text/javascript">

    layui.use(['form', 'lutil', 'element', 'code'], function () {
        var form = layui.form,
            lutil = layui.lutil,
            element = layui.element,
            layer = layui.layer;
        layui.code({
            title: 'JSON'
            ,skin: 'notepad'
        });
        form.on('checkbox(checkbox)', function (data) {
            var p_value = 0;
            var checkBoxs = $(data.elem).closest(".layui-input-block").children("input[type=checkbox]");
            $.each(checkBoxs, function (i, e) {
                if (e.checked) p_value += parseFloat(e.value);
            });
            $(data.elem).closest('form').find('input[name=result]').val(p_value === 0 ? '' : p_value);
        });
        form.on('submit(submit)', function (data) {
            var iValue = parseFloat(data.field['value']);
            $(data.form).find('input[type=checkbox]').each(function (i, e) {
                var dValue = parseFloat(e.value);
                e.checked = ((iValue & dValue) === dValue);
            });
            form.render('checkbox', $(data.form).attr('lay-filter'));
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    })

</script>

</body>
</html>